﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    layui.use(['form', 'table', 'common', 'optimizeSelectOption', 'commonTable','util'], function () {
        var form = layui.form,
            table = layui.table,
            commonTable = layui.commonTable,
            common = layui.common;
              util = layui.util;
        //加载数据
        wcLoading.close();
        //权限控制(js是值传递)
      
        toolbarDemo.innerHTML = common.authorizeButtonNew(toolbarDemo.innerHTML);
        commonTable.rendertable({
            elem: '#currentTableId',
            id: 'currentTableId',
            url: '/SystemOrganize/User/GetGridJson1',
            cols: [[
                { type: "radio", width: 50, fixed: 'left' },
               
              {
                    field: 'F_WorkState', title: '状态', width: 80, sort: true, filter: true,
                    templet: function (d) {
                         if (d.F_WorkState ==0){
                            return "<span class='layui-btn layui-btn-primary layui-border-blue layui-btn-xs'>试工期</span>";
                        }else if (d.F_WorkState ==1){
                            return "<span class='layui-btn layui-btn-primary layui-border-red layui-btn-xs'>在职</span>";
                        }else if (d.F_WorkState ==2){
                            return "<span class='layui-btn layui-btn-primary layui-border-red layui-btn-xs'>离职</span>";
                        }
                    }
                },
                {
                    field: 'F_CompanyName', title: '公司名称', width: 150, sort: true, filter: true
                },
                {
                    field: 'F_OrganizeName', title: '部门名称', width: 200, sort: true
                },
               {
                    field: 'F_DutyName', title: '岗位名称', width: 120, sort: true, filter: true
                },
                { field: 'F_RealName', title: '姓名', width: 120, sort: true, filter: true },
                {
                    field: 'F_Gender', title: '性别', width: 80, sort: true, filter: true,
                    templet: function (d) {
                        if (d.F_Gender == true) {
                            return "男";
                        } else {
                            return "女";
                        }
                    }
                },
                {
                    field: 'F_Certificate', title: '证件类型', width: 200, sort: true
                },
                {
                    field: 'F_CertificateNum', title: '证件编号', width: 200, sort: true
                },
                 {
                    field: 'F_ComAge', title: '司龄', width: 200, sort: true
                },
                 {
                    field: 'F_Age', title: '年龄', width: 200, sort: true
                },


                {
                    field: 'F_Redate', title: '入职时间', width: 160, sort: true, filter: { type: 'date[yyyy/MM/dd]' }
                },
                {
                    field: 'F_Repldate', title: '转正时间', width: 160, sort: true, filter: { type: 'date[yyyy/MM/dd]' }
                },
                {
                    field: 'F_Endate', title: '离职时间', width: 160, sort: true, filter: { type: 'date[yyyy/MM/dd]' }
                },

                { field: 'F_Description', title: '备注', minWidth: 150, sort: true, filter: true },
            ]]
        });
        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //执行搜索重载
            commonTable.reloadtable({
                elem: 'currentTableId',
                curr: 1,
                where: { keyword: data.field.txt_keyword }
            });
            return false;
        });
        //行点击事件监听，控制按钮显示
        var oneList = ["NF-add","NF-edit", "NF-details", "NF-revisepassword", "NF-disabled", "NF-enabled","NF-delete"];//选择1条显示
        commonTable.tableRowClick("radio", "currentTableFilter", "currentTableId", oneList);
        /**
         * toolbar监听事件
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            var data = table.checkStatus('currentTableId').data;
            var id = data.length > 0 ? data[0].F_Id : null;
            if (obj.event === 'add') {  // 监听删除操作
               if (id == null) {
                    common.modalMsg("未选中数据", "warning");
                    return false;
                }
                common.modalOpen({
                    title: "编辑用户",
                   url: "/ContractManagement/ContractMaintain/Form?F_UserId="+id+"&F_RealName="+encodeURI(encodeURI(data[0].F_RealName))+"&F_UserNum="+encodeURI(encodeURI(data[0].F_Num)),
                    width: "50%",
                    height: "50%",
                    //callBack: function (index) {
                    //    var iframe = "layui-layer-iframe" + index;
                    //    window.frames[iframe].submitForm();
                    //}
                });
            }
           
            else if (obj.event === 'TABLE_SEARCH') {
                var _that = $("#searchField");
                if (_that.hasClass("layui-hide")) {
                    _that.removeClass('layui-hide');
                } else {
                    _that.addClass('layui-hide');
                }
                table.resize();
            }
            return false;
        });
      
    });
</script>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset layui-hide" id="searchField">
            @*<legend>搜索信息</legend>*@
            <div>
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">关键字:</label>
                            <div class="layui-input-inline">
                                <input type="text" id="txt_keyword" name="txt_keyword" autocomplete="off" class="layui-input" placeholder="">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon">&#xe615;</i> 搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container" id="toolbar">
                <button id="NF-add" name="NF-add" authorize="yes" class="layui-btn layui-btn-sm layui-hide" lay-event="add"><i class="layui-icon">&#xe654;</i>签订</button>
            </div>
        </script>
        
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

    </div>
</div>